<template>
  <div class="login">
    <!-- <van-form ref="regForm" class="regForm" @submit="onSubmit">
      <van-cell-group inset>
        <van-field
          v-model="LoginParams.loginname"
          name="tel"
          label="用户名"
          placeholder="用户名"
          :rules="LoginRules.tel"
        />
        <van-field
          v-model="LoginParams.password"
          :type="passwordShow ? 'text' : 'password'"
          name="password"
          label="密码"
          placeholder="密码"
          :rules="LoginRules.password"
          :right-icon="passwordShow ? 'eye-o' : 'closed-eye'"
          @click-right-icon="onClickIcon"
        />
      </van-cell-group>
      <div style="margin: 16px;">
        <van-button round block type="primary" native-type="submit">
          登录
        </van-button>
      </div>
    </van-form> -->
  <van-tabs v-model:active="activeName">
    <van-tab title="账号登录" name="account"><LoginAccount></LoginAccount></van-tab>
    <van-tab title="验证码登录" name="online"><LoginOnline></LoginOnline></van-tab>
  </van-tabs>
  
  
  </div>
</template>


<script setup lang="ts">
import type {Ref} from 'vue'
import {reactive,ref} from 'vue'
// import { reg } from '@/utils/rules';
// import { showFailToast, showSuccessToast } from 'vant';
import LoginAccount from "./component/LoginAccount.vue";
import LoginOnline from './component/LoginOnline.vue';
// let activeName:Ref<string> = ref<string>("account")
   let activeName:Ref<string> = ref<string>("account")

// const AuthStore = useAuthStore()
// const {loginAndUpdateAuth} = AuthStore 

// const LoginParams = reactive<LoginParamsRaw>({
//   loginname:'',
//   password:''
// })
// const passwordShow =ref(false)
// const onClickIcon = () => {
//     passwordShow.value = !passwordShow.value;
// }
// const LoginRules = reactive<LoginRules>({
//   tel: [
//         { required: true, message: '请填写用户名/手机号/账号', trigger: "onChange" },
//         { pattern: reg.phone, message: '请填写正确的手机号', trigger: "onChange" },
//         // {validator:validateTel, message: '手机号已被注册', trigger: "onChange"}
//     ],
//     password: [
//         { required: true, message: '请填写密码', trigger: "onChange" },
//         { pattern: reg.pwd, message: '请输入6-16位的数字加字母', trigger: "onChange" },
//     ]
// })
// // const CodeParams = reactive({
// //   tel:toRef(RegParams,"tel"), //保持响应性 ref自动解包
// //   telcode:""
// // })
// // const LoginRules = reactive({
// //   tel:[{required: true, message: '请填写用户名'}],
// //   password:[{required: true, message: '请填写密码'}],
// //   telcode:[{required: true, message: '请填写密码'}]
// // })
// const onSubmit= async ()=>{
//   try{
//    let result = await loginAndUpdateAuth(LoginParams)
//   //  console.log(result);
//    showSuccessToast('登录成功')
//   }catch(err:any){
//     // console.log();
//     showFailToast(err.message)
//   }
  
// }


</script>

<style lang="scss" scoped>
.login {
    background-color: #f7f8fa;

    .regForm {
        margin-top: 50px;
    }
}
</style>